package com.findme.redis;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

public class Watcher implements Observer {
    Integer i = 0;

    public Watcher(Observable o) {
        o.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {

        System.out.println("状态发生改变：" + ((Watched) o).getData());
        if (i <= 10) {
            i++;
        }

        ((Watched) o).setData(i);
    }

}
